package com.sangfor.ssl.common;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/* loaded from: classes2.dex */
public class EnumHelperUtil {
    public static <T extends Enum<T>> T getByIntegerCode(Class<T> cls, String str, int i) {
        try {
            T[] enumConstants = cls.getEnumConstants();
            Method declaredMethod = cls.getDeclaredMethod(str, new Class[0]);
            for (T t : enumConstants) {
                if (((Integer) declaredMethod.invoke(t, new Object[0])).intValue() == i) {
                    return t;
                }
            }
            return null;
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            return null;
        } catch (IllegalArgumentException e2) {
            e2.printStackTrace();
            return null;
        } catch (NoSuchMethodException e3) {
            e3.printStackTrace();
            return null;
        } catch (SecurityException e4) {
            e4.printStackTrace();
            return null;
        } catch (InvocationTargetException e5) {
            e5.printStackTrace();
            return null;
        }
    }
}
